package com.peng.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface SignMapper {
    //添加签到时间
    @Insert("insert into tb_sign_in(user_id,sign_time) value(#{userId},now())")
    int addSign(@Param("userId") int userId);

    //查询昨天是否签到
    @Select("select count(*) from tb_sign_in where user_id=#{userId} and sign_time = #{date}")
    int selectyesterdayIsSign(@Param("userId") int userId, @Param("date") String date);

    //修改连续签到次数
    int updateContinuousSignByUserId(@Param("userId") Integer userId, @Param("number") Integer number);

    //查询用户签到次数
    @Select("select number from tb_continuous_sign where user_id = #{userId}")
    int selectSignNumber(int userId);

    //给用户添加100托福币
    @Update("update tb_account set balance = balance + 100 where user_id = #{userId}")
    int updateAccountByUserId(int userId);
}
